home *** CD-ROM | disk | FTP | other *** search
- TITLE CHEKPROC.ASM
- ;
- ;Demo program to test PROCTYPE.ASM (return processor type)
- ;
- ;This little demo (1) posts a global byte variable to 0,1,2, or 3,
- ;depending on the type processor (8086/88, 80186/188, 80286, or 80386).
- ;
- ;You can then write processor-dependent procedures and branch to the
- ;appropriate one, depending on the type processor detected!
- ;In this demo, I converted the word-sized AX return value (86H..386H)
- ;to a byte value (0..3) for ease in table lookups, etc.
- ;
- ;I also included some global definitions (1) to keep MASM busy,
- ;and (2) to make it easier on the poor programmer's memory!
- ;
- ;Returns:
- ;(1) a screen display of what CPU was discovered
- ;(2) DOS ERRORLEVEL of 0..4, depending on type CPU
- ;
- ;David Kirschbaum
- ;Toad Hall
- ;kirsch@braggvax.ARPA
-
- CPU88 EQU 0 ;8086/8088
- CPU186 EQU 1 ;80186/80188
- CPU286 EQU 2 ;80286
- CPU386 EQU 3 ;80386
- CR equ 0DH
- LF equ 0AH
-
- CSEG SEGMENT PUBLIC PARA 'CODE'
- ASSUME CS:CSEG, DS:CSEG, ES:CSEG
- ORG 100H ;a .COM program
-
- ChekProc proc near
- jmp Start ;skip over data
-
- chkmsg db 'Checking for CPU type... $'
- cpumsg db 'discovered $'
-
- typ88 db '8086/8088$'
- typ186 db '80186/80188$'
- typ286 db '80286$'
- typ386 db '80386$'
- typunk db 'Unknown$'
-
- crlf db CR,LF,'$'
-
- typtbl dw typ88,typ186,typ286,typ386,typunk
-
- cputyp db ? ;global variable
- ChekProc endp
-
- INCLUDE PROCTYPE.ASM ;include the procedure
-
- Start proc near
- mov dx,offset chkmsg ;'Checking for...'
- mov ah,9 ;DOS display msg
- int 21H
-
- call Proc_Type ;returns CPU type in AX
- xor bx,bx ;BX=0 (assume 8086/88)
- cmp ax,86H ;8086/88?
- je Got_Cpu ;yep
- inc bx ;BX=1 (80186/188)
- cmp ax,186H ;?
- je Got_Cpu ;yep
- inc bx ;BX=2 (80286)
- cmp ax,286H ;?
- je Got_Cpu ;yep
- inc bx ;BX=3 (80386)
- cmp ax,386H ;?
- je Got_Cpu ;yep
- inc bx ;bump to 4 (unknown)
-
- Got_Cpu:
- push bx ;save CPU type a sec
- shl bx,1 ;*2 for words
- mov dx,offset cpumsg ;'discovered '
- mov ah,9 ;display msg
- int 21H
-
- mov dx,[bx+typtbl] ;get cpu-type string offset
- mov ah,9 ;display msg
- int 21H
- mov dx,offset crlf ;make display neat
- mov ah,9 ;display msg
- int 21H
-
- pop ax ;restore CPU type (0..4)
- mov cputyp,al ;save 0..4 in global variable
- ;nonfunctional here, really
- mov ah,4CH ;terminate (ERRORLEVEL = CPU type)
- int 21H
- Start endp
-
- CSEG ENDS
- end ChekProc